package soilApi

import (
	"context"
	"newwater/app/soil/cmd/api/internal/svc"
	"newwater/app/soil/cmd/api/internal/types"
	"newwater/app/soil/cmd/rpc/pb"

	"github.com/tal-tech/go-zero/core/logx"
)

type CreateSoilLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCreateSoilLogic(ctx context.Context, svcCtx *svc.ServiceContext) CreateSoilLogic {
	return CreateSoilLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}
func (l *CreateSoilLogic) CreateSoil(req types.CreateAndUpdateSoilReq) (resp *types.SoilRet, err error) {
	_, err = l.svcCtx.SoilRpc.CreateSoil(l.ctx, &pb.UseSoilBody{
		Soilname:  req.Soilname,
		Crop:      req.Crop,
		Soilplace: req.Soilplace,
	})
	if err != nil {
	    return nil, err
	}


	return &types.SoilRet{
		Code: 200,
		Msg: "添加成功",
		//Data : req,
	},nil
}
